package com.zc.study.thread.多线程第三章节.thread3_1_11;

public class P {
    private String lock;

    public P(String lock) {
        this.lock = lock;
    }
    public void setValue(){
        try {
        synchronized (lock){
            if(!ValueObject.value.equals("")){
                System.out.println("生产者"+Thread.currentThread().getName()+"WAITING了");

                    lock.wait();

        }
        System.out.println("生产者"+Thread.currentThread().getName()+"RUNNABLE了");
        String value= System.currentTimeMillis()+"_"+System.nanoTime();
        ValueObject.value=value;
        lock.notify();
    }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
